import { createApp } from "vue";
import "./assets/css/base.css";
import "./assets/css/style.css";
import router from "./router";
import App from "./App.vue";
import store from "./store";
const app = createApp(App);
import directive from "./directive";
import configFun from "./configFun";
import naive from "./plus/naive";
directive(app); // 自定义指令
configFun(app); // 全局方法
naive(app); // naive ui

// 对vue进行类型补充说明
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    $MU: any;
    $toFixed: any;
    $AU: any;
  }
}

/**
 * 全局定时器
 *  页面上这样调用
 * js
    const currentTime = computed(() => {
        return store.state.currentTime;
    });
    模块   {{ transferTimeYMDHm(currentTime) }}  或 <div :data-time="currentTime"></div>
 */
setInterval(() => {
  store.state.currentTime = new Date().getTime();
}, 1000);

const getWidth = () => {
  var Width =
    window.innerWidth ||
    document.documentElement.clientWidth ||
    document.body.clientWidth;
  store.state.windowSize = Width;
  var Height =
    window.innerHeight ||
    document.documentElement.clientHeight ||
    document.body.clientHeight;
  store.state.windowSize = Width;
  store.state.windHeight = Height;
  console.log("W:" + Width + "H:" + Height);
};
getWidth();

window.onresize = function () {
  getWidth();
};
app.use(router);
app.use(store);
app.mount("#app");
